import React, { Component } from "react";

export default class RenderP extends Component {
  myRender = (name) => {
    return (
      <>
        <p>传递来的数据的名称：{name}</p>
      </>
    );
  };
  myRender2 = (name) => {
    return (
      <>
        <p>传递来的数据的名称：{name}</p>
      </>
    );
  };
  render() {
    return (
      <div>
        <DataProvider render={this.myRender} myRender2={this.myRender2}></DataProvider>
      </div>
    );
  }
}
class DataProvider extends Component {
  state = {
    name: "Tom",
  };
  render() {
    return (
      <>
        <div>
          <p>共享数据组件自己内部渲染的逻辑</p>
          {this.props.render(this.state.name)}
          {this.props.myRender2(this.state.name)}
          <button onClick={()=>this.setState({name:'yilu'})}>修改值</button>
        </div>
      </>
    );
  }
}
